package realQuestion.xinye;

import java.util.Scanner;

public class Main2 {
//TODO:2023/9/19  背包问题
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int M = scanner.nextInt();
        int n = scanner.nextInt();
        int[] weights = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i]= scanner.nextInt();
        }
        int i = countWays(M, weights);
        System.out.println(i);

    }

    static  int countWays(int M,int[]weights){
        int[] dp = new int[M + 1];
        dp[0]=1;
        for (int i = 0; i < weights.length; i++) {
            for (int j = M; j >=weights[i] ; j--) {
                dp[j]+=dp[j-weights[i]];
            }
        }
        return  dp[M];
    }


}
